//
//  IGPicListMainCollectionViewCell.m
//  jingdongfang
//
//  Created by RKL on 2018/5/10.
//  Copyright © 2018年 BOE-SBG-CTO. All rights reserved.
//

#import "IGPicListMainCollectionViewCell.h"

@implementation IGPicListMainCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self privateSetUpUI:frame];
    }
    return self;
}
- (void)privateSetUpUI:(CGRect)frame
{

    self.bgImageView = [[UIImageView alloc] init];
    [self addSubview:self.bgImageView];
    [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
        make.top.equalTo(self.mas_top);
        make.bottom.equalTo(self.mas_bottom);
    }];
    
    
    UILabel * titleLabel = [[UILabel alloc] init];
    _nameLabel = titleLabel;
    titleLabel.text = @"";
    titleLabel.textColor = [UIColor c3Color];
    titleLabel.font = [UIFont systemFontOfSize:14];
    [self addSubview:titleLabel];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.right.equalTo(self.mas_right).offset(-20);
        make.top.equalTo(self.mas_bottom).offset(-50);
        make.bottom.equalTo(self.mas_bottom);
    }];
    
    UIButton * moreImageView = [UIButton buttonWithType:UIButtonTypeCustom];
    [moreImageView setImage:[UIImage imageNamed:@"picture_more"] forState:UIControlStateNormal];
    [moreImageView addTarget:self action:@selector(moreImageBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:moreImageView];
    
    [moreImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(0);
        make.bottom.equalTo(self.mas_bottom).offset(0);
        make.size.mas_equalTo(CGSizeMake(50, 50));
    }];
}

- (void)setDataModel:(IGArtWorkModel *)dataModel
{
    _dataModel = dataModel;
    self.nameLabel.text = dataModel.title;
    [self.bgImageView sd_setImageWithURL:[NSURL URLWithString:dataModel.image] placeholderImage:[UIImage imageNamed:@"classification2"]];
}

- (void)moreImageBtnClick
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(clickMore:)])
    {
        [self.delegate clickMore:self.dataModel];
    }
}

@end










